<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
  
  <!-- Licensed under the Apache 2.0 License -->
  <link rel="stylesheet" type="text/css" href="../../../_static/fonts/open-sans/stylesheet.css" />
  <!-- Licensed under the SIL Open Font License -->
  <link rel="stylesheet" type="text/css" href="../../../_static/fonts/source-serif-pro/source-serif-pro.css" />
  <link rel="stylesheet" type="text/css" href="../../../_static/css/bootstrap.min.css" />
  <link rel="stylesheet" type="text/css" href="../../../_static/css/bootstrap-theme.min.css" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  
    <title>elastichq.model.ClusterModel &mdash; ElasticHQ latest documentation</title>
    
    <link rel="stylesheet" href="../../../_static/guzzle.css" type="text/css" />
    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../../',
        VERSION:     'latest',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../../_static/doctools.js"></script>
    <link rel="top" title="ElasticHQ latest documentation" href="../../../index.html" />
    <link rel="up" title="Module code" href="../../index.html" />
  
   

  </head>
  <body role="document">
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../http-routingtable.html" title="HTTP Routing Table"
             >routing table</a> |</li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">ElasticHQ latest documentation</a> &raquo;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> &raquo;</li> 
      </ul>
    </div>
    <div class="container-wrapper">

      <div id="mobile-toggle">
        <a href="#"><span class="glyphicon glyphicon-align-justify" aria-hidden="true"></span></a>
      </div>
  <div id="left-column">
    <div class="sphinxsidebar">
        <a href="
    ../../../index.html" class="text-logo">ElasticHQ</a>
        
<div class="sidebar-block">
  <div class="sidebar-wrapper">
    <h2>Table Of Contents</h2>
  </div>
  <div class="sidebar-toc">
    
    
      <ul>
<li class="toctree-l1"><a class="reference internal" href="../../../installation.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../user-guide.html">User Guide</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../rest-api.html">REST API</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../developer-guide.html">For Developers</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../faq.html">FAQ</a></li>
</ul>

    
  </div>
</div>
        
<div class="sidebar-block">
  <div class="sidebar-wrapper">
    <div id="main-search">
      <form class="form-inline" action="../../../search.html" method="GET" role="form">
        <div class="input-group">
          <input name="q" type="text" class="form-control" placeholder="Search...">
        </div>
        <input type="hidden" name="check_keywords" value="yes" />
        <input type="hidden" name="area" value="default" />
      </form>
    </div>
  </div>
</div>
    </div>
  </div>
        <div id="right-column">
          
          <div role="navigation" aria-label="breadcrumbs navigation">
            <ol class="breadcrumb">
              <li><a href="../../../index.html">Docs</a></li>
              
                <li><a href="../../index.html">Module code</a></li>
              
              <li>elastichq.model.ClusterModel</li>
            </ol>
          </div>
          
          <div class="document clearer body">
            
  <h1>Source code for elastichq.model.ClusterModel</h1><div class="highlight"><pre>
<span></span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">.. module:: ClusterModel</span>

<span class="sd">.. moduleauthor:: Roy Russo &lt;royrusso.gmail.com&gt;</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">from</span> <span class="nn">..globals</span> <span class="kn">import</span> <span class="n">db</span><span class="p">,</span> <span class="n">ma</span>


<div class="viewcode-block" id="ClusterModel"><a class="viewcode-back" href="../../../developers.html#elastichq.model.ClusterModel.ClusterModel">[docs]</a><span class="k">class</span> <span class="nc">ClusterModel</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Keeping it simple... cluster_name must be unique.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">__tablename__</span> <span class="o">=</span> <span class="s1">&#39;cluster&#39;</span>

    <span class="n">cluster_name</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">String</span><span class="p">,</span> <span class="n">primary_key</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
    <span class="n">cluster_ip</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">String</span><span class="p">,</span> <span class="n">nullable</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span>
    <span class="n">cluster_port</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">String</span><span class="p">,</span> <span class="n">nullable</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s2">&quot;9200&quot;</span><span class="p">)</span>
    <span class="n">cluster_scheme</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">String</span><span class="p">,</span> <span class="n">nullable</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s2">&quot;http&quot;</span><span class="p">)</span>
    <span class="n">cluster_version</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">String</span><span class="p">,</span> <span class="n">nullable</span><span class="o">=</span><span class="bp">False</span><span class="p">,</span> <span class="n">default</span><span class="o">=</span><span class="s2">&quot;http&quot;</span><span class="p">)</span>
    <span class="n">cluster_username</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">String</span><span class="p">,</span> <span class="n">nullable</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
    <span class="n">cluster_password</span> <span class="o">=</span> <span class="n">db</span><span class="o">.</span><span class="n">Column</span><span class="p">(</span><span class="n">db</span><span class="o">.</span><span class="n">String</span><span class="p">,</span> <span class="n">nullable</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
    <span class="n">cluster_connected</span> <span class="o">=</span> <span class="bp">False</span>
    <span class="n">cluster_health</span> <span class="o">=</span> <span class="bp">None</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cluster_name</span><span class="p">,</span> <span class="n">cluster_ip</span><span class="p">,</span> <span class="n">cluster_port</span><span class="o">=</span><span class="s1">&#39;9200&#39;</span><span class="p">,</span> <span class="n">cluster_scheme</span><span class="o">=</span><span class="s1">&#39;http&#39;</span><span class="p">,</span> <span class="n">username</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span>
                 <span class="n">password</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Init</span>

<span class="sd">        :param cluster_name:</span>
<span class="sd">        :param cluster_ip:</span>
<span class="sd">        :param cluster_port:</span>
<span class="sd">        :param cluster_scheme:</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cluster_name</span> <span class="o">=</span> <span class="n">cluster_name</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cluster_port</span> <span class="o">=</span> <span class="n">cluster_port</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cluster_ip</span> <span class="o">=</span> <span class="n">cluster_ip</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cluster_scheme</span> <span class="o">=</span> <span class="n">cluster_scheme</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cluster_username</span> <span class="o">=</span> <span class="n">username</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cluster_password</span> <span class="o">=</span> <span class="n">password</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">cluster_host</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Concats scheme, ip, port</span>

<span class="sd">        :return: SCHEME://IP:PORT</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">cluster_scheme</span> <span class="o">+</span> <span class="s2">&quot;://&quot;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">cluster_ip</span> <span class="o">+</span> <span class="s2">&quot;:&quot;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">cluster_port</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_basic_auth</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">cluster_username</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">cluster_password</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">True</span>
        <span class="k">return</span> <span class="bp">False</span></div>


<div class="viewcode-block" id="ClusterDTO"><a class="viewcode-back" href="../../../developers.html#elastichq.model.ClusterModel.ClusterDTO">[docs]</a><span class="k">class</span> <span class="nc">ClusterDTO</span><span class="p">(</span><span class="n">ma</span><span class="o">.</span><span class="n">ModelSchema</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Generic data transfer object for a cluster.</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">_links</span> <span class="o">=</span> <span class="n">ma</span><span class="o">.</span><span class="n">Hyperlinks</span><span class="p">({</span>
        <span class="s1">&#39;summary&#39;</span><span class="p">:</span> <span class="n">ma</span><span class="o">.</span><span class="n">AbsoluteURLFor</span><span class="p">(</span><span class="s1">&#39;.clusters_summary&#39;</span><span class="p">,</span> <span class="n">cluster_name</span><span class="o">=</span><span class="s1">&#39;&lt;cluster_name&gt;&#39;</span><span class="p">,</span> <span class="n">_external</span><span class="o">=</span><span class="bp">True</span><span class="p">),</span>
        <span class="s1">&#39;stats&#39;</span><span class="p">:</span> <span class="n">ma</span><span class="o">.</span><span class="n">AbsoluteURLFor</span><span class="p">(</span><span class="s1">&#39;.clusters_stats&#39;</span><span class="p">,</span> <span class="n">cluster_name</span><span class="o">=</span><span class="s1">&#39;&lt;cluster_name&gt;&#39;</span><span class="p">,</span> <span class="n">_external</span><span class="o">=</span><span class="bp">True</span><span class="p">),</span>
        <span class="s1">&#39;health&#39;</span><span class="p">:</span> <span class="n">ma</span><span class="o">.</span><span class="n">AbsoluteURLFor</span><span class="p">(</span><span class="s1">&#39;.clusters_health&#39;</span><span class="p">,</span> <span class="n">cluster_name</span><span class="o">=</span><span class="s1">&#39;&lt;cluster_name&gt;&#39;</span><span class="p">,</span> <span class="n">_external</span><span class="o">=</span><span class="bp">True</span><span class="p">),</span>
        <span class="s1">&#39;collection&#39;</span><span class="p">:</span> <span class="n">ma</span><span class="o">.</span><span class="n">AbsoluteURLFor</span><span class="p">(</span><span class="s1">&#39;.clusters_list&#39;</span><span class="p">)</span>
    <span class="p">})</span>

    <span class="k">class</span> <span class="nc">Meta</span><span class="p">:</span>
        <span class="n">ordered</span> <span class="o">=</span> <span class="bp">True</span>
        <span class="n">model</span> <span class="o">=</span> <span class="n">ClusterModel</span>
        <span class="n">fields</span> <span class="o">=</span> <span class="p">(</span>
            <span class="s1">&#39;cluster_name&#39;</span><span class="p">,</span> <span class="s1">&#39;cluster_ip&#39;</span><span class="p">,</span> <span class="s1">&#39;cluster_port&#39;</span><span class="p">,</span> <span class="s1">&#39;cluster_scheme&#39;</span><span class="p">,</span> <span class="s1">&#39;cluster_connected&#39;</span><span class="p">,</span> <span class="s1">&#39;cluster_host&#39;</span><span class="p">,</span>
            <span class="s1">&#39;cluster_version&#39;</span><span class="p">,</span> <span class="s1">&#39;cluster_health&#39;</span><span class="p">,</span> <span class="s1">&#39;_links&#39;</span><span class="p">)</span></div>
</pre></div>

          </div>
            
        </div>
        <div class="clearfix"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../http-routingtable.html" title="HTTP Routing Table"
             >routing table</a> |</li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">ElasticHQ latest documentation</a> &raquo;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> &raquo;</li> 
      </ul>
    </div>
<script type="text/javascript">
  $("#mobile-toggle a").click(function () {
    $("#left-column").toggle();
  });
</script>
<script type="text/javascript" src="../../../_static/js/bootstrap.js"></script>
  <div class="footer">
    &copy; Copyright 2018, ElasticHQ. Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
  </div>
  </body>
</html>